#coding=utf-8
from django.db import models

class App(models.Model):
  app_id = models.CharField(max_length=25, unique=True)
  name = models.CharField(max_length=25)
  
  port = models.CharField(max_length=5)
  
  is_gfwed = models.BooleanField(default=False)
  is_overquota = models.BooleanField(default=False)
  
  using_reverseproxy = models.BooleanField(default=False)
  
  pid = models.CharField(max_length=10, blank=True, null=True)
  
  created_at = models.DateTimeField(auto_now_add=True)
  
  def get_is_normal(self):
    if (not self.is_gfwed) and (not self.is_overquota):
      return True
    return False
  is_normal = property(fget=get_is_normal)
  
  def __unicode__(self):
    return '%s:%s'%(self.app_id, self.name)
